// 分类列表-小程序
// GET
// /category/top

import type { ApifoxModel } from '@/types/category'
import type { GoodsResult } from '@/types/goods'
import type { EmptyObject, LoginResult, ProfileParams, Result } from '@/types/log'
import { http } from '@/utils/http'

export const getCategoryTopAPI = () => {
  return http<ApifoxModel[]>({
    url: '/category/top',
    method: 'GET',
  })
}

// 商品详情
// GET
// /goods
// 规格集合一定要和skus集合下的specs 顺序保持一致
export const getGoodsAPI = (id: string) => {
  return http<GoodsResult>({
    url: `/goods?id=${id}`,
    method: 'GET',
  })
}

// 传统登录-用户名+密码
// POST
// /login
export const loginAPI = (data: { account: string; password: string }) => {
  return http<LoginResult>({
    url: '/login',
    method: 'POST',
    data,
  })
}

// 获取个人信息
// GET
// /member/profile
export const getMemberProfileAPI = () => {
  return http<Result>({
    url: '/member/profile',
    method: 'GET',
  })
}

// 会员中心-个人信息
// 修改用户头像
// POST
// /member/profile/avatar
export const updateMemberProfileAvatarAPI = (data: { file: string }) => {
  return http<Result>({
    url: '/member/profile/avatar',
    method: 'POST',
    data,
  })
}

/**
 * 修改个人信息
 * @param data 请求体参数
 */
export const putMemberProfileAPI = (data: ProfileParams) => {
  return http<Result>({
    method: 'PUT',
    url: '/member/profile',
    data,
  })
}
